unit AESlice; interface uses Memory, QuickDraw, Packages, Menus, Events, Fonts, Scrap, ToolUtils,Resources, Errors, Palettes, LowMem, AppleEvents,AEObjects, AERegistry, Errors,globals,Utilities,Stacks, Msc, AEUtility, AEWIndow, AEPicture; FUNCTION FindSliceAccessor( containerToken: AEDesc; containerClass: DescType; keyForm: DescType; keyData: AEDesc; VAR outToken: AEDesc): OSErr; function SliceEvents(var inAppleEvent, reply:AppleEvent; inToken: TokenPtr; theCommand: OSType):OSerr; implementation function SliceEvents(var inAppleEvent, reply:AppleEvent; inToken: TokenPtr; theCommand: OSType):OSerr; VAR theWindow:WindowPtr; isRoi:Boolean; oldSlice, sn:integer; s1,s2:LongInt; answer:Boolean; theError:OSErr; begin SliceEvents := noErr; if inToken^.name = 'rang' then if info^.StackInfo <> nil then begin inToken^.name := '----'; s1 := inToken^.index; s2 := inToken^.thru; CheckIndex(s1,1,info^.StackInfo^.nSlices); CheckIndex(s2,1,info^.StackInfo^.nSlices); inToken^.thru := 0; if info^.StackInfo <> nil then with info^, info^.StackInfo^ do for sn := s2 downto s1 do begin inToken^.index := sn; SliceEvents := SliceEvents(inAppleEvent, reply, inToken, theCommand); end; exit(SliceEvents); end; theWindow := inToken^.containerWindow; if theWindow <> nil then if info^.StackInfo <> nil then with info^, info^.StackInfo^ do begin if (inToken^.index < 1) or (inToken^.index > nSlices) then begin isRoi := RoiShowing; oldSlice := CurrentSlice; CurrentSlice := inToken^.index; SelectSlice(CurrentSlice); if (theCommand = 'slct') then begin if isRoi then KillRoi; if theCommand = 'slct' then begin UpdatePicWindow; UpdateTitleBar; end; if isRoi then RestoreRoi; oldSlice := CurrentSlice; end else if theCommand = 'Chos' then oldSlice := CurrentSlice else if theCommand = 'delo' then DeleteSlice else if theCommand = 'AddC' then answer := AddSlice(true) else SliceEvents := PictureEvents(inAppleEvent, reply,inToken,theCommand); CurrentSlice := oldSlice; if CurrentSlice > nSlices then CurrentSlice := nSlices; SelectSlice(CurrentSlice); end; end else SliceEvents := PictureEvents(inAppleEvent, reply,inToken,theCommand) else SliceEvents := errAEEventNotHandled; end; FUNCTION FindSliceAccessor( containerToken: AEDesc; containerClass: DescType; keyForm: DescType; keyData: AEDesc; VAR outToken: AEDesc): OSErr; VAR pt:Point; theToken:ObjectToken; cont:TokenPtr; theError:OSErr; theName:str255; theType:OSType; k:integer; theWindow:WindowPtr; inf:InfoPtr; BEGIN theToken.index := 0; theToken.thru := 0; FindSliceAccessor := noErr; if (containerToken.dataHandle <> nil) then begin cont := TokenPtr(containerToken.dataHandle^); theToken.containerWindow := cont^.containerWindow; theToken.containerInfo := cont^.containerInfo; end else begin theToken.containerWindow := info^.wptr; theToken.containerInfo := info; end; theToken.containerType := 'Stak'; theToken.name := 'Slic'; theToken.index := 0; theToken.thru := 0; if keyForm = formAbsolutePosition then begin if keyData.descriptorType = 'list' then begin theError := PointFromDesc(keyData, pt); theToken.index := pt.h; theToken.thru := pt.v; gObjIndex := theToken.index; FindSliceAccessor := AECreateDesc('Slic', @theToken, SizeOf(ObjectToken), outToken); end else if keyData.descriptorType = typeAbsoluteOrdinal then begin if info^.StackInfo <> nil then begin AbsoluteOrdinal(keyData, @theToken, info^.StackInfo^.nSlices); if theToken.containerWindow = nil then begin theToken.containerWindow := info^.wptr; theToken.containerInfo := info; end; theToken.containerType := 'Stak'; FindSliceAccessor := AECreateDesc('Slic', @theToken, SizeOf(ObjectToken), outToken) end; end else begin theError := ShortFromDesc(keyData, k); theToken.index := k; FindSliceAccessor := AECreateDesc('Slic', @theToken, SizeOf(ObjectToken), outToken); end; end else if keyForm = formRange THEN begin theError := GetRange(keyData, theToken.index, theToken.thru); FindSliceAccessor := AECreateDesc('Slic', @theToken, SizeOf(ObjectToken), outToken); end ELSE FindSliceAccessor := errAEEventNotHandled; END; end.